def CountDigit(number,digit ):
    count = 0
    num = str(number)
    dig = str(digit)
    for n in num:
      if n==dig:
        count += 1
    return count
number, digit = input().split()
number = int(number)
digit = int(digit)
count = CountDigit(number, digit)
print("Number of digit 2 in " + str(number) + ":", count)